package com.onedec.menu.service.impl;

import com.onedec.menu.dao.OnedecRoleDao;
import com.onedec.menu.entity.OnedecDeptExample;
import com.onedec.menu.entity.OnedecRole;
import com.onedec.menu.entity.OnedecRoleExample;
import com.onedec.menu.service.RoleService;
import org.apache.catalina.Role;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
@Service
public class RoleServiceImpl implements RoleService {
    @Autowired
    private OnedecRoleDao onedecRoleDao;
    @Override
    public List<OnedecRole> selectAll() {
        return onedecRoleDao.selectByExample(null);
    }

    @Override
    public List<OnedecRole> selectByName(String name) {
        OnedecRoleExample onedecRoleExample = new OnedecRoleExample();
        OnedecRoleExample.Criteria or = onedecRoleExample.or();
        or.andRoleNameEqualTo(name);
        return onedecRoleDao.selectByExample(onedecRoleExample);
    }

    @Override
    public void insert(OnedecRole onedecRole) {
        onedecRoleDao.insertSelective(onedecRole);
    }
}
